import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Lily
 * Date: 2024-10-14
 * Time: 19:56
 */
public class test_3 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNext()) { // 注意 while 处理多个 case
            int m = in.nextInt();
            int n = in.nextInt();
            char[][] chars = new char[m][n];
            for (int i = 0; i < m; i++) {
                char[] array = in.next().toCharArray();
                chars[i] = array;
            }
            int[][] dp = new int[m + 1][n + 1];
            for (int i = 1; i < m + 1; i++) {
                for (int j = 1; j < n + 1; j++) {
                    int grade = 0;
                    if (chars[i - 1][j - 1] == 'l') {
                        grade = 4;
                    } else if (chars[i - 1][j - 1] == 'o') {
                        grade = 3;
                    } else if (chars[i - 1][j - 1] == 'v') {
                        grade = 2;
                    } else if (chars[i - 1][j - 1] == 'e') {
                        grade = 1;
                    }
                    dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]) + grade;
                }
            }
            System.out.println(dp[m][n]);
        }
    }
}
